package com.example.springboot.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Description 配置类
 * @Author zf
 * @Date 2020/4/28 13:40
 * @Version 1.0
 */
@Configuration
public class WebConfig extends WebMvcConfigurationSupport {

    static final String IMG_PATH = System.getProperty("user.dir") + "/file-static/";

    /**
     * 访问静态资源
     * 这个方法是用来配置静态资源的，比如html，js，css，等等
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/file-static/**")
                .addResourceLocations("file:" + IMG_PATH);
    }

}
